<?php   
    // Access-Control-Allow-Origin

    // CORS (配置跨域资源共享)
    // @header("Access-Control-Allow-Origin:*");  // 允许所有人访问
    // @header("Access-Control-Allow-Origin:http://127.0.0.1:8848");  // 允许所有人访问


    @include_once("conn.php");

    $user = $_POST["user"];
    $pwd = $_POST["pwd"];
    $phone = $_POST["phone"];
    $email = $_POST["email"];

    if($user&&$pwd&&$phone&&$email){
        $insert = "insert into `userinfo`(user,pwd,phone,email) values('$user','$pwd','$phone','$email')";

        mysqli_query($conn,$insert);
    
        $rows = mysqli_affected_rows($conn);
    
        $msg = array();
        if($rows>0){
            $msg["status"] = true;
            $msg["msg"] = "注册成功";
        }else{
            $msg["status"] = false;
            $msg["msg"] = "注册失败";
            $msg["sql"] = $insert;
        }
    
        
    }else{
        $msg = array();
        $msg["status"] = false;
        $msg["msg"] = "请输出完整信息";
    }
    
    echo json_encode($msg);
    

?>